import { fieldWrapper } from './fieldWrapper';
import { sortWrapper } from './sortWrapper';

export const orderWrapper = (entity, field: string, sort: string) => {
  if (!field) {
    field = 'id';
  } else {
    field = fieldWrapper(entity, field);
  }
  if (!sort) {
    sort = 'DESC';
  } else {
    sort = sortWrapper(sort);
  }

  const order = { [field]: sort };
  return order;
};
